#include <conio.h> 
#include <dos.h> 

int infor[][12]=
{
    {261, 69, 73, 78, 82, 87, 92, 98, 103, 110, 116, 123}, 
    {293, 139, 147, 156, 165, 175, 185, 196, 208, 220, 233, 247}, 
    {329, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494}, 
    {349, 554, 587, 622, 659, 698, 740, 784, 831, 880, 932, 988}, 
    {392, 1109, 1175, 1244, 1318, 1397, 1480, 1568, 1661, 1760, 1865, 1976}, 
    {440, 2160, 2288, 2422, 2565, 2716, 2877, 3047, 3226, 3417, 3618, 3832}, 
    {493, 4297, 4551, 4819, 5104, 5405, 5724, 6061, 6419, 6798, 7166, 7625}
};     

void Sleep(int mseconds)
{
    int i;
    for(i=0;i<1000;i++) delay(mseconds);
}    

void Make_Sound(int num)
{
    sound(num);
    Sleep(25);
    sound(num+5);
    Sleep(25);
    sound(num-5);
    Sleep(25);
    sound(num+3);
    Sleep(25);
    sound(num-3);
    nosound();
}    
    
void Input()
{
    int tone,col;
    char row;
    again:
    clrscr();
    printf("Please input the tone fo the music:(0:C,1:C+,2:D,3:D+,4:E,5:F,6:F+,7:G,8:G+,9:A,10:A+,11:B)");
    scanf("%d",&col);
    if(col<0||col>11) goto again;
    printf("Let's play the music:\n");
    again2:
    row=getch();
    switch(row)
    {
        case'1':printf("%d\n",infor[0][col]);Make_Sound(infor[0][col]);break;
        case'2':printf("%d\n",infor[1][col]);Make_Sound(infor[1][col]);break;
        case'3':printf("%d\n",infor[2][col]);Make_Sound(infor[2][col]);break;
        case'4':printf("%d\n",infor[3][col]);Make_Sound(infor[3][col]);break;
        case'5':printf("%d\n",infor[4][col]);Make_Sound(infor[4][col]);break;
        case'6':printf("%d\n",infor[5][col]);Make_Sound(infor[5][col]);break;
        case'7':printf("%d\n",infor[6][col]);Make_Sound(infor[6][col]);break;
        case 27:exit(0);break;
        default:goto again2;
    }
    goto again2;
}

main()
{
    Input();
}    
        
     
